package internal

import (
	"encoding/json"
	"io"
	"net/http"
	"yutooaisdk/camera"

	"github.com/gin-gonic/gin"
)

// OpenCameraRequest 打开相机【请求体】
type OpenCameraModel struct {
	SelectedCamera *camera.CameraBaseInfo `json:"selectedCamera,omitempty"`
}

// 1.调用GetCameraList获取相机列表以及正在使用的相机
// 2.调用OpenCamera接口打开相机列表中的某个相机
func OpenCamera(c *gin.Context) {
	//Todo
	var data OpenCameraModel
	boby, _ := io.ReadAll(c.Request.Body)
	err := json.Unmarshal(boby, &data)
	camera.Open(uint(data.SelectedCamera.ID), data.SelectedCamera.SupportInfo)
	c.JSON(http.StatusOK, gin.H{
		"code": 0,
		"msg":  err,
	})
}
